package com.efast.dmom.mes.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.entity.StartWorkEntity;
import com.efast.dmom.mes.service.StartWorkService;

@Controller
@RequestMapping("/startWork")
public class StartWorkController {
	
	@Autowired
	private StartWorkService startWorkService;
	
	//开工
	@RequestMapping(value = "/start")
	public @ResponseBody ResultBean startWork(@RequestBody StartWorkEntity startWorkEntity) {
		ResultBean resultBean = new ResultBean(true);
		try {
			resultBean = startWorkService.StartWork(startWorkEntity);
		} catch (RuntimeException e) {
			resultBean.setErrorMessage(e.getMessage());
			return resultBean;
		}
		return resultBean;
	}
	
	//重新开工
	@RequestMapping(value = "/afreshStartWorking")
	public @ResponseBody ResultBean afreshStartWorking(@RequestBody StartWorkEntity startWorkEntity) {
		ResultBean resultBean = new ResultBean(true);
		try {
			resultBean = startWorkService.afreshStartWorking(startWorkEntity);
		} catch (RuntimeException e) {
			resultBean.setErrorMessage(e.getMessage());
			return resultBean;
		}
		return resultBean;
	}

}
